﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Aplicacion_Vista_CrearNuevoUsuario : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        String nomRol = (String)Session["nombreRol"];
        String nomU = (String)Session["nombreUsuario"];

        if (nomRol == null || nomRol.Length <= 0 || nomU == null || nomU.Length <= 0)
        {
            Response.Redirect("Inicio.aspx");
        }
        
        ControladorCrearNuevoUsuario control = new ControladorCrearNuevoUsuario();
        control.cargarRoles(DropDownList1, Button1, TextBox2);
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Session["nombreRol"] = null;
        Session["nombreUsuario"] = null;
        Session["idRol"] = null;
        Session.Abandon();
        Response.Redirect("Inicio.aspx", true);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ControladorCrearNuevoUsuario control = new ControladorCrearNuevoUsuario();
        String nr = TextBox1.Text;
        String ap = TextBox3.Text;
        String am = TextBox4.Text;
        String te = TextBox5.Text;
        String ma = TextBox6.Text + "@" + TextBox7.Text;
        String iRol = DropDownList1.SelectedValue.ToString();
        control.insertUsuario(nr, ap, am, te, ma, iRol, TextBox2, Button1);
    }
}